package cn.yuanqiao.archive.supervision.domain;

import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import cn.yuanqiao.common.utils.SnowflakeIdGenerator;
import cn.yuanqiao.manage.domain.ManageTenant;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * 下发通知对象 YQ_ISSUED_NOTICE
 * 
 * @author gw
 * @date 2024-03-14
 */
@Data
public class YqIssuedNotice extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键 */
    private Long id;

    /** 标题 */
    private String title;

    /** 年度 */
    private String year;

    /** 单位id */
    private Long registeredUnitId;
    /** 单位名称 */
    private String registeredUnit;

    /** 年检通知是否下发 (0.未下发 1下发) */
    private String isIssueNotice;

    /** 通知内容 */
    private String noticeContent;

    /** 创建人 */
    private String createUser;

    /** 修改人 */
    private String updateUser;

    /** 状态（1.未上报
     *      2.已上报
     *      3.已退回
     *      4.已通过）
     */
    private String state;

    /** 是否删除（0.删除1.未删除） */
    private Integer isDelete;

    /** 租户码 */
    private String tenantCode;

    /** 退回原因 */
    private String returnReason;

    /** 截止时间 */
    private String deadline;

    /** 附件表 */
    private List<YqAttachments> attachmentsList;

    /** 1材料上报、2上报情况 状态*/
    private Integer materialState;

    public static YqIssuedNotice init(AnnualVo vo, ManageTenant manageTenant, String date) {
        Long issueId = SnowflakeIdGenerator.generateId();
        YqIssuedNotice issuedNotice = new YqIssuedNotice();
        issuedNotice.setId(issueId);
        issuedNotice.setTitle(vo.getTitle());
        issuedNotice.setTenantCode(SecurityUtils.getTenantCode());
        issuedNotice.setYear(vo.getYear());
        issuedNotice.setNoticeContent(vo.getNoticeContent());
        issuedNotice.setDeadline(date);
        issuedNotice.setCreateUser(SecurityUtils.getUsername());
        issuedNotice.setCreateTime(new Date());
        issuedNotice.setState("1");
        issuedNotice.setRegisteredUnitId(manageTenant.getId());
        issuedNotice.setTenantCode(manageTenant.getTenantCode());
        issuedNotice.setIsIssueNotice("1");
        return issuedNotice;
    }

}
